use serde::Deserialize;

use crate::domains::params::{CreateTodoParam, UpdateTodoParam, UpdateTodoStatusParam};

// API 请求参数对象
#[derive(Debug, Deserialize)]
pub struct CreateTodoRequest {
    pub title: String,
    pub description: String,
}

impl From<CreateTodoRequest> for CreateTodoParam {
    fn from(req: CreateTodoRequest) -> Self {
        Self {
            title: req.title,
            description: req.description,
        }
    }
}

#[derive(Debug, Deserialize)]
pub struct UpdateTodoRequest {
    /// Todo 标题
    pub title: String,
    /// Todo 描述
    pub description: String,
}

impl From<UpdateTodoRequest> for UpdateTodoParam {
    fn from(req: UpdateTodoRequest) -> Self {
        Self {
            title: req.title,
            description: req.description,
        }
    }
}

#[derive(Debug, Deserialize)]
pub struct UpdateTodoStatusRequest {
    pub status: String,
}

impl From<UpdateTodoStatusRequest> for UpdateTodoStatusParam {
    fn from(req: UpdateTodoStatusRequest) -> Self {
        Self { status: req.status }
    }
}
